:root {
  --bg: #0f172a; /* default slate-900 */
  --card: rgba(255,255,255,0.08);
  --text: #ffffff;
  --muted: rgba(255,255,255,0.7);
  --accent: #22d3ee; /* cyan-400 */
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 22px;
  --modal-bg: rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background 0.3s ease;
}

.wrap {
  width: min(100%, 1100px);
  padding: 18px;
  display: grid;
  gap: 14px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex; align-items:center; gap:10px;
  font-weight: 800; letter-spacing: .3px; font-size: clamp(18px, 2.2vw, 24px);
}
.brand .dot { 
  width: 10px; height: 10px; border-radius:999px; 
  background: var(--accent); 
  box-shadow: 0 0 0 4px rgba(34,211,238,.25); 
}

.toolbar { display:flex; align-items:center; gap:10px; flex-wrap: wrap; }
.btn, button, input[type="color"] { cursor: pointer; }

.btn {
  padding: 12px 16px; border: 1px solid rgba(255,255,255,.12);
  background: var(--card); color: var(--text);
  border-radius: 14px; font-weight: 600; backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  transition: transform .08s ease, opacity .2s ease, background .2s ease, border-color .2s ease;
  user-select: none;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: linear-gradient(180deg, rgba(34,211,238,.9), rgba(34,211,238,.75)); color: #00242a; border-color: transparent; }
.btn.warning { background: linear-gradient(180deg, rgba(248,113,113,.95), rgba(248,113,113,.75)); color: #2a0000; border-color: transparent; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.18); }

.mode-switch { display:flex; background: var(--card); border:1px solid rgba(255,255,255,.12); border-radius: 14px; overflow:hidden; }
.mode-switch button { flex:1; padding: 10px 14px; background: transparent; color: var(--muted); border:0; font-size: 14px; }
.mode-switch button.active { background: rgba(255,255,255,.12); color: var(--text); font-weight: 700; }

.panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.screen {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.big-time {
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-size: clamp(44px, 10vw, 96px);
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.1;
  text-shadow: 0 2px 16px rgba(0,0,0,.4);
}
.sub-info { 
  text-align:center; 
  color: var(--muted); 
  font-size: clamp(12px, 1.8vw, 14px); 
  min-height: 20px;
}

.controls { display:flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.controls .btn { min-width: 50px; }

/* Time input */
.time-input { display:flex; gap: 8px; justify-content: center; align-items:center; flex-wrap: wrap; }
.time-input input[type="number"] { 
  width: 90px; padding: 12px 10px; background: transparent; border-radius: 12px; 
  border:1px solid rgba(255,255,255,.18); color: var(--text); font-size: 16px; text-align:center; 
}
.time-input label { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media(min-width: 880px) {
  .grid { grid-template-columns: 1.2fr .8fr; }
}

.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid; gap: 12px;
}
.card h3 { 
  margin: 0; font-size: 14px; color: var(--muted); 
  font-weight: 700; letter-spacing: .3px; text-transform: uppercase; 
}

.laps { max-height: 340px; overflow: auto; border-radius: 14px; }
.laps table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.laps tr { border-bottom: 1px dashed rgba(255,255,255,.12); }
.laps th, .laps td { text-align: left; padding: 10px 8px; font-size: 14px; }
.laps th { position: sticky; top: 0; background: rgba(0,0,0,.25); backdrop-filter: blur(4px); }
.right { text-align: right; }

.info-content p { margin: 8px 0; font-size: 14px; }
.info-content ul { margin: 8px 0; padding-left: 20px; }
.info-content li { margin: 4px 0; font-size: 14px; }

.footer { opacity:.8; font-size: 12px; text-align:center; color: var(--muted); }

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  width: min(90%, 500px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  background: rgba(255,255,255,.1);
}

.modal-body {
  padding: 20px;
}

.modal-body .prefs {
  margin-bottom: 24px;
}

.modal-body h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--text);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.custom-color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}

.custom-color-btn input[type="color"] {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

.checkbox-label, .select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 14px;
}

.select-label {
  flex-wrap: wrap;
}

.select-label select {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: rgb(128,128,128);
  padding: 6px 10px;
}

.hidden { display: none !important; }

/* Estilos para tela cheia */
body.fullscreen .wrap {
  width: 100%;
  max-width: 100%;
  padding: 10px;
}

body.fullscreen .grid {
  display: none;
}

body.fullscreen .screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

body.fullscreen .big-time {
  font-size: clamp(50px, 20vw, 150px);
}

body.fullscreen header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 15px;
  z-index: 100;
}

body.fullscreen .toolbar .btn:not(#btnFullscreen) {
  opacity: 0.7;
}

body.fullscreen .toolbar .btn:not(#btnFullscreen):hover {
  opacity: 1;
}

/* Ocultar campos de tempo em tela cheia */
body.fullscreen #countdownInputs {
  display: none !important;
}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  animation: fadeIn 0.2s ease;
}

/* Responsividade melhorada */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .toolbar {
    width: 100%;
    justify-content: space-between;
  }
  
  .color-swatches {
    justify-content: center;
  }
  
  .modal-content {
    width: 95%;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .mode-switch button {
    padding: 8px 10px;
    font-size: 12px;
  }
  
  .time-input {
    flex-direction: column;
    align-items: stretch;
  }
  
  .time-input label {
    text-align: center;
  }
  
  .controls .btn {
    min-width: 44px;
    padding: 10px;
  }
  
  .controls .btn i {
    margin: 0;
  }
}